<?php
	require_once("../conexion/conexion.php");
	
	function BuscaValores($liq)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select LiqTotalImp,LiqTotalNoImp,LiqTotalDescto,LiqLiquido
				from liquidacion where LiqCod='".$liq."'";
	
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$valor = mysql_fetch_array($res);
		$con->cerrarBD();
		return $valor;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
a:link {color:#0033FF;} /* Link no visitado*/
a:visited {text-decoration:none; color:#666666;} /*Link visitado*/
a:hover {color:#990000;} /*Mouse sobre el link*/
</style>
<script>

function Eliminar(valor)
{
	id = document.getElementById("tbExp").rows[valor].cells[0].innerText;
	//numero = document.getElementById("tbOtros").rows[valor].cells[1].innerText;
	//alert(id+" "+numero);
	$.ajax({
					type: 'POST',
					url: 'Remuneracion/Eliminar_Liquidacion.php',
					data: {id:id},
					success: function(data) {
						$('#eliminar').html(data);
						Direccionar();
					}
				})
}

function Direccionar()
{
	//alert('dir');
		$.ajax({
				type: 'POST',
				url: 'Remuneracion/Carga_Busqueda_Liquidacion.php',
				data: $('#form_Busqueda').serialize(),
				success: function(data) {
					$('#capa').html(data);
				}
			})
}
</script>
</head>

<body>
<form name="carga_busqueda_exp" id="carga_busqueda_exp" method="post">
<?php
	
	extract($_POST);
 
	//empleado
 	if ($cmb_Cliente=="0")
	{
		$cmb_Cliente="null";
	}
	else
	{$cmb_Cliente="'".$cmb_Cliente."'";}
	
	//mes
 	if ($cmb_Mes=="0")
	{
		$cmb_Mes="null";
	}
	
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select distinct
				LiqCod,
				date_format(ItemLiqFecha,'%d/%m/%Y') as fecha,
				EmpNombre,
				EmpApPaterno,
				EmpApMaterno,
				EmpSueldo
				
				
				from itemliquidacion il
				inner join Empleado e on
				e.EmpRut=il.EmpRut 
				
				where
				(($cmb_Cliente is NULL) or (il.EmpRut = $cmb_Cliente)) and
				(($cmb_Mes is NULL) or (ItemLiqMes = $cmb_Mes))
				order by EmpNombre";
	
			$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			$fila = mysql_num_rows($res);
			$con->cerrarBD();
			if($fila >0)
			{?>
			<div class="cabecera2">
			<table border="0" class="fija" cellpadding="0" cellspacing="0" id="tbExp" width="100%">
			<thead class="fija">
      		  <tr class="fija">
			  	<th width="2%" class="fija">id</th>
			  	<th width="35%" class="fija">empleado</th>
				<th width="8%" class="fija">sueldo</th>
			    <th width="10%" class="fija">fecha</th>
				<th width="10%" class="fija">imp.</th>
				<th width="10%" class="fija">no imp.</th>
			    <th width="10%" class="fija">dscto</th>
				<th width="13%" class="fija">final</th>
				<th width="2%" class="fija">&nbsp;</th>
			  </tr>
			 </thead>
			 <tbody class="fija">
				<tr class="fija"><td colspan="9" class="fija">&nbsp;</td></tr>
			<?php
			$aux = 2;
			while($reg = mysql_fetch_array($res))
			{
				$valor = BuscaValores($reg[0]);
				
				if(($aux % 2)==0)
				{
					echo "<tr class='filaImpar' id='".$aux."'>";
					echo "<td width=\"2%\" style='text-align:center'>".$reg[0]."</td>";
					echo "<td width=\"35%\" style='text-align:lefth;padding-left:5px;'>".$reg[2].' '.$reg[3].' '.$reg[4]."</td>";
					echo "<td width=\"8%\" style='text-align:center;'>".number_format($reg[5],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:center;'>".$reg[1]."</td>";
					echo "<td width=\"10%\" style='text-align:center;'>".number_format($valor[0],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:right;padding-right:10px;'>".number_format($valor[1],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:center'>".number_format($valor[2],0,',','.')."</td>";
					echo "<td width=\"13%\" style='text-align:center'>".number_format($valor[3],0,',','.')."</td>";
					echo "<td width=\"2%\" style='text-align:center'><img src='imagen/delete_icon.gif' width='16' height='16' alt='Eliminar' style='cursor: pointer;' onclick='Eliminar($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class='filaPar' id='".$aux."'>";
					echo "<td width=\"2%\" style='text-align:center'>".$reg[0]."</td>";
					echo "<td width=\"35%\" style='text-align:lefth;padding-left:5px;'>".$reg[2].' '.$reg[3].' '.$reg[4]."</td>";
					echo "<td width=\"8%\" style='text-align:center;'>".number_format($reg[5],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:center;'>".$reg[1]."</td>";
					echo "<td width=\"10%\" style='text-align:center;'>".number_format($valor[0],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:right;padding-right:10px;'>".number_format($valor[1],0,',','.')."</td>";
					echo "<td width=\"10%\" style='text-align:center'>".number_format($valor[2],0,',','.')."</td>";
					echo "<td width=\"13%\" style='text-align:center'>".number_format($valor[3],0,',','.')."</td>";
					echo "<td width=\"2%\" style='text-align:center'><img src='imagen/delete_icon.gif' width='16' height='16' alt='Eliminar' style='cursor: pointer;' onclick='Eliminar($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
			}
			?>
      </tbody>
	  </table>
	  </div>
	  <?php }
			else
			{echo "<label style='font-size:16px; color:#CC3333; font-weight:bold;'>No Existen Resultados para la B&uacute;squeda</label>";}
 ?>
<div id="eliminar"></div>
</form>
</body>
</html>
